//
//  HistoryPicListController.swift
//  QualityControlSystem
//
//  Created by dundun on 17/1/12.
//  Copyright © 2017年 com.mask. All rights reserved.
//

import UIKit

class HistoryPicListController: UITableViewController {
    
    var processId: String?
    var modelArr: [HistoryPicInfo]?
    
    init(style: UITableViewStyle, processId: String?) {
        self.processId = processId
        super.init(style: style)
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        view.backgroundColor = Color.bgGray
        tableView.register(UINib(nibName: "HistoryPicListCell", bundle: nil), forCellReuseIdentifier: "historyPicListCell")
        loadData()
    }

    func loadData() {
        HTTPRequest.historyUploadListWith(processId: processId!, completion: { response in
            
        })
//        modelArr = [HistoryPicInfo]()
//        for _ in 1...5 {
//            let model = HistoryPicInfo()
//            model.uploadTime = "2016-12-13 23:35"
//            model.uploadPeople = "小王"
//            modelArr?.append(model)
//        }
    }

    // MARK: - Table view data source

    override func numberOfSections(in tableView: UITableView) -> Int {
        return modelArr?.count ?? 0
    }

    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 1
    }

    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let historyPicListCell = tableView.dequeueReusableCell(withIdentifier: "historyPicListCell", for: indexPath) as? HistoryPicListCell
        historyPicListCell?.accessoryType = .disclosureIndicator
        historyPicListCell?.infoModel = modelArr?[indexPath.section]
        return historyPicListCell!
    }

    // MARK: - Table view delegate
    
    override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return 100
    }
    
    override func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
        return 5
    }
    
    override func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
        return 0.1
    }
    
    override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        tableView.deselectRow(at: indexPath, animated: true)
    }
}
